package by.bsu.scs.util.manager;

import javax.servlet.http.Cookie;

/**
 * @author Alexey Hursevich
 * @version 1.0
 * 
 * Responsible for cookies creation.
 */
public class CookiesManager {

	// max cookies age = 7 days
	private static final int MAX_AGE = 60 * 60 * 24 * 7;
	
	public static final String C_KEY_USER = "SCS_USER";
	public static final String C_KEY_PASS = "SCS_PASS";
	public static final String C_KEY_SAVE = "SCS_SAVE";
	
	/**
	 * Creates new cookie and sets expiration time.
	 * 
	 * @param key
	 * @param value
	 * @return cookie
	 */
	public static synchronized Cookie createCookie(String key, String value) {
		Cookie cookie = new Cookie(key, value);
		cookie.setMaxAge(MAX_AGE);
		return cookie;
	}
}
